package mogowtools.client;

import mogowtools.client.fx.Properties;
import mogowtools.client.fx.Slider;
import mogowtools.client.fx.Style;
import mogowtools.client.fx.StyleListener;
import mogowtools.client.fx.Styles;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class test implements EntryPoint {

  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
    final Button button = new Button("Style test");
    final Button button2 = new Button("Styles test");
    final Button button3 = new Button("Slider test");
    final Label label = new Label("Style");
    final Label label2 = new Label("Styles");
    final Label label3 = new Label("Slider");

    RootPanel.get("slot1").add(button);
    RootPanel.get("slot2").add(label);
    RootPanel.get("slot3").add(button2);
    RootPanel.get("slot4").add(label2);
    RootPanel.get().add(button3);
    RootPanel.get().add(label3);
    
    final Style Fx = new Style(button, "width");
    Fx.set("100");
    
    Fx.addListener(new StyleListener() {

		public void onCancel() {
			label.setText("onCancel");
		}

		public void onComplete() {
			label.setText("onComplete");
		}

		public void onStart() {
			label.setText("onStart");
		} 
		});
    
    button.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
          if (label.getText().equals(""))
          {
          	label.setText("Style :)");
            Fx.start("200");
          }
          else
          {
          	label.setText("");
            Fx.start("100");
          }
        }
    });

    final Properties prop = new Properties();
    prop.addProperty("width", "100", "200");
    prop.addProperty("height", "50", "100");

    final Properties prop2 = new Properties();
    prop2.addProperty("width", "200", "100");
    prop2.addProperty("height", "100", "50");
    
    final Styles Fxs = new Styles(button2, prop);
    
    button2.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        if (label2.getText().equals(""))
        {
        	label2.setText("Styles ;)");
        	Fxs.setCssAttributes(prop);
        	Fxs.start();
        }
        else
        {
        	label2.setText("");
        	Fxs.setCssAttributes(prop2);
        	Fxs.start();
        }
      }
    });

    final Slider s = new Slider(label3);
    button2.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
          if (label2.getText().equals(""))
          {
          	label2.setText("Styles ;)");
          	Fxs.setCssAttributes(prop);
          	Fxs.start();
          }
          else
          {
          	label2.setText("");
          	Fxs.setCssAttributes(prop2);
          	Fxs.start();
          }
        }
      });
    
  }
}
